import { isEmptyObject } from "../../utils";

export class AddressRule {
  constructor(required) {
    this.required = required;
    this.asyncValidator = (rule, address) => {
      if (!required) {
        return Promise.resolve();
      } else {
        if (isEmptyObject(address)) {
          return Promise.reject("请添加收货地址");
        }
        return Promise.resolve();
      }
    };
  }
}
